//
//  AFHTTPSessionManager+Share.m
//  BPRequestTool_Example
//
//  Created by SiYugui on 2020/4/29.
//  Copyright © 2020年 xuhongji. All rights reserved.
//

#import "AFHTTPSessionManager+Share.h"

@implementation AFHTTPSessionManager (Share)
+ (instancetype)sharedManager {
    static AFHTTPSessionManager *manager;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [AFHTTPSessionManager manager];
        
        AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
        //AFN ~ HTTPS
        // NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"https" ofType:@"cer"];
        //NSData * certData =[NSData dataWithContentsOfFile:cerPath];
        //NSSet * certSet = [[NSSet alloc] initWithObjects:certData, nil];
        
        // 设置证书
        //[securityPolicy setPinnedCertificates:certSet];
        // 是否允许,NO-- 不允许无效的证书
        [securityPolicy setAllowInvalidCertificates:YES];
        [securityPolicy setValidatesDomainName:NO];
        manager.securityPolicy = securityPolicy;
        
    });
    return manager;
}
@end
